package cc.yugu.yhdw.common.domain.basic;

import cc.yugu.yhdw.common.annotation.Transient;
import cc.yugu.yhdw.common.entity.json.DateTimeSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 用户实体类
 *
 * @Date:Created in 2018/7/25 14:47
 * @Author:
 * @Modified By: zjn 2018/7/25 14:47
 */
public class User extends UserInfo {
    public enum Type {
        PLATFORM(1, "总部"),
        AGENT(2, "运营商"),
        AGENCY(3, "代理商"),
        SUPPLIER(4, "厂商");


        private final int value;
        private final String name;

        private Type(int value, String name){
            this.value = value;
            this.name = name;
        }

        public static Map<Integer,String> map = new HashMap<Integer,String>();
        static {
            for (Type e : Type.values()) {
                map.put( e.getValue(),e.getName());
            }
        }

        public static String getName(int value) {
            return map.get(value);
        }

        public int getValue() {
            return value;
        }

        public String getName() {
            return name;
        }
    }

    Integer agentId;   //代理商ID
    Integer agencyId; //代理商id
    Integer supplierId; //厂商id
    int adminFlag; //系统管理员
    int type; //用户类型
    String username; //登录名称
    String password; //密码
    String realName;//真实姓名
    String mail; //电子邮件
    String tel; //座机号码
    String mobile;//手机号
    String memo; //备注
    Date lastLoginTime; //上次登录
    Integer roleId; //角色ID
    Integer deptId; //部门ID
    int activeFlag; //是否启用
    String portrait;//头像
    Date createTime; //创建时间

    @Transient
    String deptName, roleName, agencyName,typeName,agentName;

    public String getAgentName() {
        return agentName;
    }

    public void setAgentName(String agentName) {
        this.agentName = agentName;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Integer getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Integer supplierId) {
        this.supplierId = supplierId;
    }

    public String getAgencyName() {
        return agencyName;
    }

    public void setAgencyName(String agencyName) {
        this.agencyName = agencyName;
    }

    public Integer getAgentId() {
        return agentId;
    }

    public void setAgentId(Integer agentId) {
        this.agentId = agentId;
    }

    public Integer getAgencyId() {
        return agencyId;
    }

    public void setAgencyId(Integer agencyId) {
        this.agencyId = agencyId;
    }

    public int getAdminFlag() {
        return adminFlag;
    }

    public void setAdminFlag(int adminFlag) {
        this.adminFlag = adminFlag;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public Integer getDeptId() {
        return deptId;
    }

    public void setDeptId(Integer deptId) {
        this.deptId = deptId;
    }

    public int getActiveFlag() {
        return activeFlag;
    }

    public void setActiveFlag(int activeFlag) {
        this.activeFlag = activeFlag;
    }

    public String getPortrait() {
        return portrait;
    }

    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    @Override
    public String toString() {
        return "User{" +
                "agentId=" + agentId +
                ", adminFlag=" + adminFlag +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", realName='" + realName + '\'' +
                ", mail='" + mail + '\'' +
                ", tel='" + tel + '\'' +
                ", mobile='" + mobile + '\'' +
                ", memo='" + memo + '\'' +
                ", lastLoginTime=" + lastLoginTime +
                ", roleId=" + roleId +
                ", deptId=" + deptId +
                ", activeFlag=" + activeFlag +
                ", portrait='" + portrait + '\'' +
                ", createTime=" + createTime +
                ", agencyId=" + agencyId +
                ", deptName='" + deptName + '\'' +
                ", roleName='" + roleName + '\'' +
                ", agencyName='" + agencyName + '\'' +
                '}';
    }
}
